<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>继承</title>
</head>
<body>
    <h1 class="mytitle">按下F12打开控制台查看</h1>
<script>
    function Ainimal(name){
        this.name = name;
    }
    Ainimal.prototype.type = function(){
        console.log("猫科动物");
    }

    function Cat(name){
        Ainimal.call(this, name);
    }
    Cat.prototype = new Ainimal();//利用原型获取方法
    var obj1 = new Ainimal("猫");
    console.log(obj1);
    console.log(obj1.type);
</script>   
</body>
</html>